/**
 * Created by ZFL on 2017/9/17.
 */
var vm=new Vue({
    el:'#squadron',
    data:{
        level:'',   //用户等级
        corpsLogo:'',  //战队logo
        corpsName:'',  //战队名称
        rank:0,       //排名
        teamNum:0,    //战队人数
        totalSales:0, //销售总额
        userImage:'',
        userId:0
    },
})
Vue.filter('price',function(value){
    return divideNumber(value,100);
})

function appInit(){
    PageInit();

}


function PageInit(){

    var userId=$.getPara('userId');
    //vm.userId=userId;
    //vm.userImage= $.getPara('userImage');
    vm.userImage='http://ow7g1orcv.bkt.clouddn.com/file/user/20170927200206053.png'
    vm.userId=$.getPara('userId');
    var title='战队佣金';
    getUserInfo();    //用户信息
    squadronInfo();   //我的战队信息

}
function toSquadronRank(){
    var u = navigator.userAgent;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if(isAndroid){
        //alert("安卓系统");
        JSAndroid.toCommission();
    }else if(isiOS){
        //alert("苹果系统");
        //window.webkit.messageHandlers.shareBooking.postMessage(this.data.activity.id,this.data.activity.join_company_id);
        toCommission();
    }
}
var userId=$.getPara('userId');
//得到用户的信息
function getUserInfo(){
    $.ajaxHandler({
        model:function(){
            var obj={};
            obj.userId=userId;
            return obj;
        },
        visibleTime: 0,
        dataType: "json",
        visible:'hide',
        api:'yg_baijiaapp/user/getUserEntityByIdNoPassword',
        success:function(res){
            if(res.code==10000){
                var data=res.data;
               vm.level=data.level;
            }
        }

    })
}
//我的战队信息
function squadronInfo(){
    $.ajaxHandler({
        model:function(){
            var obj={};
            obj.userId=userId;
            console.log(obj)
            return obj;
        },
        visibleTime: 0,
        dataType: "json",
        visible:'hide',
        api:'yg_baijiaapp/statistics/getHuiMeiTeamInfo',
        success:function(result){
            if(result.code==10000){
                var data=result.data;
                vm.corpsLogo=data.corpsLogo;
                vm.corpsName=data.corpsName;
                vm.rank=data.rank;
                vm.teamNum=data.teamNum;
                vm.totalSales=data.totalSales;
            }else{
                YDUI.dialog.toast(result.message, 'error', 1000);
            }
        }
    })
}
